package com.apes.fn.server.workDesk.model;

import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.ApesConst;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * @program: apes-server
 * @description:
 * @author: lws
 * @create: 2023-02-13 10:28
 **/
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = StockWarring.CONST_TABLE_NAME)
public class StockWarring extends BaseModel {
    public static final String CONST_TABLE_NAME = "RCL_STOCK_WARRING";

    @Id
    @Column(name = "id", nullable = false, length = 24)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "库存预警", padding = 12)
    private String id;

    @Column(name = "LOCATION_ID", length = 64)
    @Comment("库区编码")
    private String locationId;

    @Column(name = "LOCATION_NAME", length = 64)
    @Comment("库区名称")
    private String locationName;

    @Column(name = "DEPT_ID", length = 64)
    @Comment("部门编码")
    private String deptId;

    @Column(name = "DEPT_NAME", length = 64)
    @Comment("部门名称")
    private String deptName;

    @Column(name = "PRODUCT_ID", length = 64)
    @Comment("商品编码")
    private String productId;

    @Column(name = "PRODUCT_NAME", length = 64)
    @Comment("商品名称")
    private String productName;

    @Column(name = "USABLE_QTY", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("可用数")
    private double usableQty = 0;

    @Column(name = "SAFETY_STOCK_QTY", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("安全库存")
    private double safetyStockQty = 0;

    @Column(name = "sale_7", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("近七天销量")
    private double saleSeven = 0;   // 完成时间七天内的零售明细数量

    @Column(name = "sale_30", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("近三十天销量")
    private double saleThirty = 0;  // 完成时间三十天内的零售明细数量
}
